clear
set more off


local tstr0 "A. Claim rate by size: 2020Q2-2020Q4"
local tstr1 "B. Claim rate by size: 2021Q1-2021Q3"

use "$statadir/by_size", clear
niceloglabels num_emp if num_emp > 0, style(125) local(labname)

forval post = 0/1 {
    twoway scatter any_orig num_emp if num_emp > 0 & post == `post' & orig >= 5, mcolor(gs0) || ///
        scatter any_either num_emp if num_emp > 0 & post == `post' & amend >= 5, mcolor(gs8) msymbol(circle_hollow) ///
        title("`tstr`post''") ///
        xscale(log) xlabel(`labname') ///
			xtitle("Number of employees (log scale)") ///
			xline(500, lpattern("--") lcolor(gray)) ///
			ytitle("Share with ERC") ///
			scheme(s1color) ///
            legend(off)
    graph save g`post'.gph, replace
	
	
	twoway scatter any_orig num_emp if num_emp > 0 & post == `post' & orig >= 5, mcolor(gs0) || ///
        scatter any_either num_emp if num_emp > 0 & post == `post' & amend >= 5, mcolor(gs8) msymbol(circle_hollow) ///
        title("`tstr`post''") ///
        xscale(log) xlabel(`labname') ///
			xtitle("Number of employees (log scale)") ///
			xline(500, lpattern("--") lcolor(gray)) ///
			ytitle("Share with ERC") ///
			scheme(s1color) ///
            legend(order(1 "On original return" 2 "On original or amended return") cols(2))
    graph save g`post'_leg.gph, replace
    
}

grc1leg g0_leg.gph g1_leg.gph, scheme(s1color) ycommon leg(g0_leg.gph)
graph display, ysize(9) xsize(16)
graph export "$outdir/figures/by_size.eps", replace



graph combine g0.gph g1.gph, scheme(s1color) ycommon
graph display, ysize(4) xsize(16)
graph save gtop.gph, replace




local tstr0 "C. Histogram of ERC/wages: 2020Q2-2020Q4"
local tstr1 "D. Histogram of ERC/wages: 2021Q1-2021Q3"

use "$statadir/ertc_histogram", clear

forval post = 0/1 {
    twoway scatter f rbin if post == `post' & i == 0, mcolor(gs0) || ///
        scatter f rbin if post == `post' & i == 1, mcolor(gs8) msymbol(circle_hollow) ///
            xtitle("Ratio of ERTC to total wages") ///
            ytitle("Density") ///
            scheme(s1color) ///
            legend(order(1 "On original return" 2 "On original or amended return") cols(2)) ///
            title("`tstr`post''") 
            
    graph save g`post'.gph, replace
}
grc1leg g0.gph g1.gph, ycommon leg(g0.gph) scheme(s1color)
graph display, ysize(4) xsize(16)
graph save gbottom.gph, replace


graph combine gtop.gph gbottom.gph, scheme(s1color) cols(1)

graph export "$outdir/figures/g2020_2021.eps", replace


